﻿using System.Data;
using Dapper;
using DataServer.ApplicationLib.Entities;

namespace DataServer.ApplicationLib.Repositories
{
    public class ReportRepository :  IReportRepository
    {
        private readonly IDbConnection _dbConnection;

        public ReportRepository(IDbConnection dbConnection)
        {
            _dbConnection = dbConnection;
        }

        public ReportEntity GetReport(string reportId)
        {
            // string sql = "select * from fpm_ds_report where enabled = 1 and report_id= @reportId";

            var sql = "";

            return _dbConnection
                .QueryFirst<ReportEntity>(sql, new { reportId });
        }

        public IList<ReportFieldEntity> GetReportFieldByReportId(string reportId)
        {
            // string sql = "select * from fpm_ds_report_fields where report_id = @reportId";

            var sql = "";

            return _dbConnection
                .Query<ReportFieldEntity>(sql, reportId)
                .ToList();
        }
    }
}